import { instance } from '../request'

const request1 = instance

/**
 * 创建组
 * @param groupName 组名
 */
export const createGroupApi = (groupName: string): PromiseRes =>
  request1.post('/group/create', { groupName })

/**
 * 修改组名
 */
export const updateGroupApi = (
  groupId: string,
  groupName: string
): PromiseRes => request1.post('/group/update', { groupId, groupName })

/**
 * 删除组
 * @param groupId 组id
 */
export const deleteGroupApi = (groupId: string): PromiseRes =>
  request1.delete(`/group/delete?groupId=${groupId}`)

/**
 * 获取用户所有组的信息
 */
export const getGroupApi = (): PromiseRes<getGroupItf[]> =>
  request1.get(`/group/get `)

/**
 * 分页获取组中的图片
 * @param groupId
 * @param page
 * @param pageSize
 */
export const getGroupImagesApi = (
  groupId: string,
  page: number,
  pageSize: number
): PromiseRes<getPageGroupImagesItf> =>
  request1.get(
    `/group/getImages?groupId=${groupId}&page=${page}&pageSize=${pageSize}`
  )

/**
 * 删除图片
 * @param imageId
 */
export const deleteImageApi = (imageId: string): PromiseRes =>
  request1.delete(`/group/deleteImage?imageId=${imageId}`)

/**
 * 恢复图片
 * @param imageId
 */
export const recoverImageApi = (imageId: string): PromiseRes =>
  request1.post(`/group/recoverImage`, { imageId })

/**
 * 分页获取删除的图片
 * @param page
 * @param pageSize
 */
export const getDeleteImagesApi = (
  page: number,
  pageSize: number
): PromiseRes<getPageGroupImagesItf> =>
  request1.get(`/group/getDeleteImages?page=${page}&pageSize=${pageSize}`)
